package utils

import (
	"time"
	"math/rand"
)

func CurrentTime() string {
	return time.Now().Format("2006-01-02 15:04:05")
}

type CustomerError struct {
	Msg string // 错误描述
}

func (e *CustomerError) Error() string { return e.Msg }

var (
	codes   = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
	codeLen = len(codes)
)
func RandStr(len int) string {
	data := make([]byte, len)
	rand.Seed(time.Now().UnixNano())
	for i := 0; i < len; i++ {
		idx := rand.Intn(codeLen)
		data[i] = codes[idx]
	}
	return string(data)
}
